package cn.jinbyte.core.exception;

import cn.jinbyte.core.model.ApiCode;
import lombok.Getter;

import static cn.jinbyte.core.model.ApiCode.ERROR;

/**
 * 默认系统异常
 */
@Getter
public class SysException extends RuntimeException implements SysError {

    private final ApiCode code;
    private final String message;

    public SysException(String message) {
        this.code = ERROR;
        this.message = message;
    }

    public SysException(ApiCode code, String message) {
        this.code = code;
        this.message = message;
    }

    public SysException(Throwable throwable) {
        this.code = ERROR;
        this.message = throwable.getMessage();
    }
}
